
	<!DOCTYPE html>
	<html>
		<head>
			<meta charset="UTF-8">
			<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
			<title>报工列表</title>
			<link rel="stylesheet" href="css/AllStyle.css" />
			<link rel="stylesheet" href="css/iconfont.css" />
			<script type="text/javascript" src="js/common.js" ></script>
			<script type="text/javascript" src="js/companydata.js" ></script>
<!--			  <script type="text/javascript" src="js/loadData.js" ></script>-->
			<script type="text/javascript" src="js/data.js" ></script>
			<script type="text/javascript" src="js/tmpl.js" ></script>
		</head>
		<body>
			<!-- 页头 -->
			<section>
				<script type="text/javascript">
					AllPageHeader()
				</script>
			</section>

			<section class="AllContent" id="pullrefresh">
				<section>
					<form>
						<div class="FormStyle">
							<div class="ScanInput" style="width:90%;margin:10px auto;">
								<p style="margin: 0px;"><input name="procName" id="procName" class="bg-focus form-control" type="text" placeholder="工序名称,构件二维码"></p>
								<p style="margin: 0px;"><button id="bt_query" type="button" style="font-size:0.9em" onclick="querySend('down',this);">查询</button></p>
							</div>
							<p class="TheResults" style="margin:0px 5%;padding:0px;padding-bottom:10px;"></p>
							<div class=""><p class="relative alert alert-success"></p></div>
						</div>

						<div class="grid-body" id="cententbody"></div>
					</form>
					<div id="sendList">
						<img style="width: 40%;margin:20px auto;display: block;" src="images/loading5.gif">
					</div>
				</section>
			</section>

			<div id="dddd"></div>
		</body>
		<script type="text/javascript" src="js/jquery.min.js" ></script>
		<script>var h5pullDown = true;</script>
		<script type="text/javascript" src="js/mui.js" ></script>
		<script type="text/javascript" src="js/mui.pullToRefresh.js"></script>
		<script type="text/javascript" src="js/mui.pullToRefresh.material.js"></script>
		<script type="text/javascript">
			let pageNo = 0; //当前页数
			let pageSize = 20; //页数大小
			let totalPages = 1; //总页数
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					down: {
						contentdown : "<div style='text-align:center;fonr-size:0.95em;color:#ccc;'>下拉刷新</div>",
						contentover : '<div style="width:100%;background:#fff;"><img style="width: 20%;margin:0px auto;display:block;" src="images/loading5_.jpg" /><p style="text-align:center;color:#777;padding:5px 0px;">释放加载...</p></div>',
						contentrefresh : '<div style="width:100%;background:#fff;"><img style="width: 20%;margin:0px auto;display:block;" src="images/loading5.gif" /><p style="text-align:center;color:#777;padding:5px 0px;">正在加载...</p></div>',
						callback: function () {
							var self = this;
							pageNo = 1;
							setTimeout(function() {
								querySend('down',self);
							},100);
						}
					},
					up: {
						contentrefresh: "<div style='text-align:center;fonr-size:0.95em;color:#ccc;'>正在加载...</div>",
						contentnomore: "<div style='text-align:center;fonr-size:0.95em;color:#ccc;'>没有更多工序信息了</div>",
						auto: true,
						callback: function() {
							var self = this;
							setTimeout(function () {
								if (pageNo < totalPages){
									pageNo = pageNo + 1;
									querySend('up',self);
								}
							},1000);
						}
					}
				}
			});
			$('.AllHeader li:eq(1)').text('工序列表');
			$('.AllHeader li:eq(2)').html('<img style="width:28px" src="images/Scan.png">')

			mui.plusReady(function(){
				//扫描器
				document.getElementById('Scanner').addEventListener('tap', function() {
					mui.openWindow({
						url: 'Scanner.html?etk=6',
						id:'Scanner.html'
					});
				});
			});

			//添加refresh自定义事件监听
			window.addEventListener('procList',function(){
				var id = event.detail.id;
				$('#procName').val(id);
				querySend("down",this);
			});


			$(function(){
				if(getCookie("token") === null || getCookie("token") === ''){
					window.location.href='login.html';
					return;
				}
			});

			function querySend(type,obj) {
				var procName = document.getElementById("procName").value;
				$.ajax({
					headers:{
						"X-Access-Token":getCookie("token")
					},
					type: "GET",
					url: getServerUrl()+"/procedure/proc/phoneList",
					dataType: 'json', //从php返回的值以 JSON方式 解释
					contentType: 'application/json',
					data: {'userName':getCookie("userName"),'procName':procName}, //
					success: function (json) {//如果调用php成功
						sendlist = json.result;
						var chtml = '';
						if (!empty(sendlist)) {
							chtml = '<ul>';
							for (var i = 0; i < sendlist.length; i++) {
								if (!empty(sendlist[i])) {
									var reg = new RegExp('[0-9]{19}')
									if(procName!=undefined && procName!= null && procName!='' && reg.test(procName)){
										if (sendlist.length===1){
											$.ajax({
												headers: {
													"X-Access-Token": getCookie("token")
												},
												type: "GET",
												contentType: 'application/json',
												url: getServerUrl() + "/task/selectIdByProcAndFrame/"+procName+"/"+sendlist[i].id,
												success: function (json) {//如果调用php成功
													mui.openWindow({
														url:'reporting.html?taskId='+json+'&procId='+sendlist[0].id,
														id:'reporting.html',
														createNew:true
													});
												},error:function(json){
													alertMessage(JSON.stringify(json))
												}
											});
										}
										chtml = chtml + '<li class="list" ext_id="'+ sendlist[i].id +'" fram_id="'+ procName +'">';
									}else {
										chtml = chtml + '<li class="list" ext_id="'+ sendlist[i].id +'">';
									}
									chtml = chtml + '<div class="ProductsListContent">';
									chtml = chtml + '<div class="ProductsDetails">';
									chtml = chtml + '<p style="font-size: 20px;">' + sendlist[i].name + '</p>';
									chtml = chtml + '</div>';
									chtml = chtml + '</div>';
									chtml = chtml + '</li>';
								}
							}
							chtml = chtml + '</ul>';
						}
						$("#sendList").html(chtml);
						pageNo = json.result.current;
						totalPages = json.result.pages;
						if ((pageNo === totalPages || totalPages === 0) && type === 'up'){
							obj.endPullupToRefresh(true);
						}
						showpage(json.total_results,json.page_no,json.page_size,getwindowhref());
						if (type !== undefined && type !== null && obj !== undefined && obj !== null){
							if (type === 'up'){
								if(pageNo < totalPages){
									obj.endPullupToRefresh();
								}else{
									obj.endPullupToRefresh(true);
								}
							}else if (type === 'down'){
								obj.endPullDownToRefresh();
							}
						}
					},
					error:function(json){
						alertMessage(JSON.stringify(json))
					}
				});
			}
			mui('body').on('tap', '.list', function() {
				var ext_id = $(this).attr('ext_id');
				var fram_id = $(this).attr('fram_id');
				if (fram_id!=undefined && fram_id!=null){
					$.ajax({
						headers: {
							"X-Access-Token": getCookie("token")
						},
						type: "GET",
						contentType: 'application/json',
						url: getServerUrl() + "/task/selectIdByProcAndFrame/"+fram_id+"/"+ext_id,
						success: function (json) {//如果调用php成功
							mui.openWindow({
								url:'reporting.html?taskId='+json+'&procId='+ext_id,
								id:'reporting.html',
								createNew:true
							});
						},error:function(json){
							alertMessage(JSON.stringify(json))
						}
					});
				}else {
					mui.openWindow({
						url:'procEngineeringList.html?procId='+ext_id,
						id:'procEngineeringList.html',
						createNew:true
					});
				}
			});
			mui('body').on('tap', '.myFirstPage', function() {
				mui.openWindow({
					url:'supper.html',
					id:'supper.html',
				})
			});

		</script>
		<style>
			p{
				margin-top: 10px;
				color: #AAAAAA;
			}
		</style>
	</html>
